Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 15, 2025

The test_json_serialization test intermittently fails in CI with relative differences ~1.13e-07, exceeding the default assert_allclose tolerance of 1e-07. This occurs due to non-deterministic random data generation in the test.

Changes

  • tests/light_curve_ext/test_feature.py: Added fixed random seed rng=0 to gen_lc() call to ensure deterministic test data generation
# Before
data = gen_lc(n_obs)
assert_allclose(values, values_from_to_json)

# After  
data = gen_lc(n_obs, rng=0)
assert_allclose(values, values_from_to_json)

This approach makes the test fully deterministic by ensuring the same random data is generated every run, eliminating flakiness at the source while maintaining the strict default tolerance (rtol=1e-7). This is consistent with the test parametrization which already uses rng=0 for feature generation.

Original prompt

This section details on the original issue you should resolve

<issue_title>Test failure in CI</issue_title>
<issue_description>Some test sometimes fails in CI. We should either make it more deterministic, or set much larger rtol, or remake it. Or find a bug =)

tests/light_curve_ext/test_feature.py:434: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

args = (<function assert_allclose.<locals>.compare at 0x7f6420a18c10>, array([ 9.09579623e+00, -5.40383904e+00, -8.64983171e-...904e+00, -8.64983172e-01,  2.19817431e+00,
        8.17213286e+01,  1.27377227e-04,  2.04551540e+00,  8.13644738e-01]))
kwds = {'equal_nan': True, 'err_msg': '', 'header': 'Not equal to tolerance rtol=1e-07, atol=0', 'strict': False, ...}

    @wraps(func)
    def inner(*args, **kwds):
        with self._recreate_cm():
>           return func(*args, **kwds)
E           AssertionError: 
E           Not equal to tolerance rtol=1e-07, atol=0
E           
E           Mismatched elements: 1 / 8 (12.5%)
E           Max absolute difference among violations: 1.43896006e-11
E           Max relative difference among violations: 1.12968393e-07
E            ACTUAL: array([ 9.095796e+00, -5.403839e+00, -8.649832e-01,  2.198174e+00,
E                   8.172133e+01,  1.273772e-04,  2.045515e+00,  8.136447e-01])
E            DESIRED: array([ 9.095796e+00, -5.403839e+00, -8.649832e-01,  2.198174e+00,
E                   8.172133e+01,  1.273772e-04,  2.045515e+00,  8.136447e-01])

https://github.com/light-curve/light-curve-python/actions/runs/19382889947/job/55464766907?pr=576</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Fix intermittent test failure in CI Fix flaky test_json_serialization by relaxing numerical tolerance Nov 15, 2025
Copilot AI requested a review from hombit November 15, 2025 03:04
Copilot finished work on behalf of hombit November 15, 2025 03:04
@hombit hombit force-pushed the copilot/fix-ci-test-failure branch from 5866cbd to f1c3c8e Compare November 15, 2025 03:05
Copy link
Member

@hombit hombit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot let's better try to use gen_lc with fixed random seed

@codecov
Copy link

codecov bot commented Nov 15, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.60%. Comparing base (94c6faa) to head (9837bda).
⚠️ Report is 4 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #582   +/-   ##
=======================================
  Coverage   82.60%   82.60%           
=======================================
  Files           9        9           
  Lines        2604     2604           
=======================================
  Hits         2151     2151           
  Misses        453      453           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor Author

Copilot AI commented Nov 15, 2025

@copilot let's better try to use gen_lc with fixed random seed

Done in b9fe806. Changed gen_lc(n_obs) to gen_lc(n_obs, rng=0) to use deterministic test data, and reverted the tolerance relaxation to keep the default strict checking.

Copilot AI changed the title Fix flaky test_json_serialization by relaxing numerical tolerance Fix flaky test_json_serialization by using deterministic test data Nov 15, 2025
Copilot AI requested a review from hombit November 15, 2025 03:20
Copilot finished work on behalf of hombit November 15, 2025 03:20
@codspeed-hq
Copy link

codspeed-hq bot commented Nov 15, 2025

CodSpeed Performance Report

Merging #582 will not alter performance

Comparing copilot/fix-ci-test-failure (9837bda) with master (94c6faa)

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

Summary

✅ 106 untouched
⏩ 106 skipped1

Footnotes

  1. 106 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

Copilot AI and others added 2 commits November 15, 2025 05:52
Co-authored-by: hombit <1784493+hombit@users.noreply.github.com>
Co-authored-by: hombit <1784493+hombit@users.noreply.github.com>
@hombit hombit force-pushed the copilot/fix-ci-test-failure branch from b9fe806 to 74c9ab8 Compare November 15, 2025 10:52
…ignore

Co-authored-by: hombit <1784493+hombit@users.noreply.github.com>
Copilot AI requested a review from hombit November 15, 2025 22:28
Copilot finished work on behalf of hombit November 15, 2025 22:28
@hombit hombit marked this pull request as ready for review November 15, 2025 23:31
@hombit hombit enabled auto-merge November 15, 2025 23:32
@hombit hombit merged commit c5ba089 into master Nov 18, 2025
82 checks passed
@hombit hombit deleted the copilot/fix-ci-test-failure branch November 18, 2025 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test failure in CI

2 participants